package aad.storyboard.model;

import java.io.FileNotFoundException;

import aad.storyboard.model.Image;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;

public class BitmapImage extends Image {
        
        private BitmapDrawable drawable;
        
        static {
    		ImageFactory.getInstance().registerClass(".png",new BitmapImage());
    		ImageFactory.getInstance().registerClass(".jpg",new BitmapImage());
    		ImageFactory.getInstance().registerClass(".gif",new BitmapImage());
    	}
        
        public BitmapImage(Resources r, int id) throws FileNotFoundException {
                super(r,id);
                
                // TODO Auto-generated constructor stub
        }
        
        private BitmapImage(){super();}
        @Override
        protected Bitmap constructBitmap(Resources res, int id) throws FileNotFoundException{
                Bitmap mBitmap = BitmapFactory.decodeResource(res, id);
                this.height = mBitmap.getHeight();
                this.width = mBitmap.getWidth();
                return mBitmap;
        }
        @Override
        protected Drawable constructDrawable(Resources res, int iD) {
                // TODO Auto-generated method stub
                return null;
        }
        @Override
        public Drawable getDrawable() {
                // TODO Auto-generated method stub
                return this.drawable;
        }
		@Override
		public Image createImage(Resources r, int id) throws FileNotFoundException {
			// TODO Auto-generated method stub
			return new BitmapImage(r,id);
		}

}
